package web.Servlet;

import Service.TaobaoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "deleteServlet",urlPatterns = "/sc")
public class deleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        ArrayList arrayList = new ArrayList();
        arrayList.add(id);

        TaobaoService taobaoService = new TaobaoService();
        int delete = taobaoService.delete(arrayList);
        if(delete!=0){
            req.getRequestDispatcher("/tb").forward(req,resp);
        }else {
            req.getRequestDispatcher("/sc").forward(req,resp);
        }
    }
}
